import java.awt.*;
import java.awt.event.*;

public
class ConnectDialog extends Dialog implements ActionListener{
	protected Button bOK;
	protected Button bCancel;

	protected TextField tfHost;
	protected TextField tfPort;
	protected TextField tfNick;

	protected Label lHost;
	protected Label lPort;
	protected Label lNick;

	public boolean OKClicked;
	public String host;
	public String port;

	public ConnectDialog(Frame parent)
	{
		super(parent, true);
		setTitle("Connect dialog");
		WindowWatcher windowWatcher = new WindowWatcher();
		addWindowListener(windowWatcher);
		initLayout();
		setVisible(true);
	}
	public void initLayout()
	{
		setLayout(new GridLayout(3, 2));
		setSize(250, 100);

		tfHost = new TextField();
		tfHost.setSize(100, 20);
		tfPort = new TextField();
		tfPort.setSize(100, 20);

		lHost = new Label("Host");
		lHost.setSize(100, 20);
		lPort = new Label("Port");
		lPort.setSize(100, 20);

		bOK = new Button("OK");
		bOK.setSize(100, 20);
		bOK.addActionListener(this);

		bCancel = new Button("Cancel");
		bCancel.setSize(100, 20);
		bCancel.addActionListener(this);

		add(lHost);
		add(tfHost);
		add(lPort);
		add(tfPort);
		add(bOK);
		add(bCancel);
	}
	public void actionPerformed(ActionEvent evt)
	{
		String tmp = evt.getActionCommand();
		if (tmp.equals("OK")){
			host = tfHost.getText();
			port = tfPort.getText();
			OKClicked = true;
			setVisible(false);
		}
		else if (tmp.equals("Cancel")){
			OKClicked = false;
			setVisible(false);
		}
	}
	class WindowWatcher extends WindowAdapter
	{
		public void windowClosing(WindowEvent evt)
		{
			dispose();
		}
	}
}
